import { defineStore } from 'pinia'
import type { AntdDropdownOption, TenantSystem } from '@/types/system'
import { ref } from 'vue'

// 定义 Store
export const useTenantSystemStore = defineStore(
  'system',
  () => {

    const state = ref<TenantSystem>({
      pid: 0,
      defaultToken: '',
      
    })


    const setPId = (pid: number) => {
      state.value.pid = pid
    }

    const setToken = (token: string) => {
      state.value.defaultToken = token
    }

    // 记得 return
    return {
      state,
      setPId,
      setToken,
    }
  },
  {
    // 网页端配置
    // persist: true,
    // 小程序端配置
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key)
        },
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
      },
    },
  },
)
